package cn.iocoder.yudao.module.chat.dal.redis.history.gpt;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class ChatSessionRedisDao {
    private static final String CHAT_REDIS_SESSION_KEY = "CHAT_REDIS_SESSION_KEY:";

    @Resource
    private RedisTemplate<String, String> redisTemplate;

    public String getSession(Long userId){
        return redisTemplate.opsForValue().get(CHAT_REDIS_SESSION_KEY + userId);
    }
    public void insertSession(Long userId, String sessionId){
        redisTemplate.opsForValue().set(CHAT_REDIS_SESSION_KEY + userId,sessionId);
    }

}
